package com.lb.myeam.common.utils;

import java.io.UnsupportedEncodingException;

/**
 * liubiao
 */

public class StringUtil {
	/**
	 * 
	 * @param str
	 * @return 返回转码后的字符串或者空白字符串
	 */
	public static String str2UTF8(String str) {
		if (null != str) {
			try {
				return new String(str.getBytes("iso-8859-1"), "UTF-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	public static String str2GBK(String str) {
		if (null != str) {
			try {
				return new String(str.getBytes("iso-8859-1"), "GBK");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	public static String str2Encoding(String str,String encoding){
		if (null != str) {
			try {
				return new String(str.getBytes("iso-8859-1"), "UTF-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}
